import React from 'react';
import {Table} from 'antd';
import {injectIntl} from './intl';
import PropTypes from 'prop-types';
import {columns} from './constants';
import {TABLE} from '../constants';
// eslint-disable-next-line react/prefer-stateless-function
export class TablePanelMonth extends React.PureComponent {
    render() {
        const {conditions, dataType} = this.props;
        return (
            <Table
                className="white-space-nowrap"
                rowKey="id"
                dataSource={dataType}
                columns={columns(conditions, dataType)}
                loading={this.props.loading}
                pagination={false}
                {...TABLE}/>
        );
    }
}

TablePanelMonth.propTypes = {
    conditions: PropTypes.object.isRequired,
    dataType: PropTypes.array.isRequired,
    intl: PropTypes.object,
    loading: PropTypes.bool,
};

import {connect} from 'react-redux';
import selectorFactory from 'Shared/utils/immutableToJsSelectorFactory';
const getConditions = selectorFactory(['page', 'appState', 'queryCondition']);
const getDataType = selectorFactory(['page', 'domainData', 'listType', 'data']);
const mapStateToProps = state => ({
    dataType: getDataType(state),
    conditions: getConditions(state),
    loading: state.getIn(['page', 'domainData', 'listType', 'isFetching']),
});
export default connect(mapStateToProps, null)(injectIntl(TablePanelMonth));
